<?php require_once 'library/User.php'; ?>
<?php
$Counselor = new Counselor();
$Counselor->checkUser();
$Counselor->isAdmin();
$saved = null;
if (isset($_POST['save'])) {
    unset($_POST['save']);
    if (array_key_exists('data_table_length', $_POST)) {
        unset($_POST['data_table_length']);
    }
    $saved = $Counselor->save($_POST);
}
if (isset($_GET['isAjax'])) {
    $Counselor->getData($_POST);
    return;
} elseif (isset($_GET['isAjaxUpdate'])) {
    $update = $Counselor->update($_POST);
    echo json_encode($update);
    return;
} elseif (isset($_GET['isAjaxDelete'])) {
    $deleted = $Counselor->delete($_POST['id']);
    echo json_encode($deleted);
    return;
}

if (isset($_GET['logout'])) {
    $Counselor->dologout();
}

?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>E-Major : Counselor</title>

    <link rel="stylesheet" href="lib/jquery-ui/css/smoothness/jquery-ui-1.8.15.custom.css" type="text/css"/>
    <link rel="stylesheet" href="lib/harvesthq-chosen/chosen.css" type="text/css"/>
    <link rel="stylesheet" href="lib/elfinder/css/elfinder.full.css" type="text/css"/>
    <link rel="stylesheet" href="lib/visualize/visualize.css" media="all" type="text/css"/>
    <link rel="stylesheet" href="lib/datatables/css/table_jui.css" type="text/css"/>
    <link rel="stylesheet" href="lib/gritter/css/jquery.gritter.css" type="text/css"/>
    <link rel="stylesheet" href="lib/fancybox/jquery.fancybox-1.3.4.css" type="text/css"/>
    <link rel="stylesheet" href="lib/file-uploader/fileuploader.css" type="text/css"/>
    <link rel="stylesheet" href="lib/timepicker-addon/jquery-ui-timepicker-addon.css" type="text/css"/>
    <link rel="stylesheet" href="lib/fullcalendar/fullcalendar.css" type="text/css"/>
    <link rel="stylesheet" href="css/style.css" media="all" type="text/css"/>

    <script type="text/javascript" src="js/head.min.js"></script>


</head>


<body class="bg_c sidebar fixed ">
<div id="top_bar">
    <div class="wrapper cf">
        <ul class="fl">
             <li class="sep">Welcome <a href="#"><?php echo $Counselor->get('uname') !== false ? ucfirst($Counselor->get('uname')) : ''; ?></a></li>
            <li class="sep"><a href="index.php?uid=0">Logout</a></li>
        </ul>
        <ul class="fr">
            <li><strong>E-Major Counselor</strong></li>
        </ul>
    </div>
</div>

<div id="header">
    <div class="wrapper cf">
        <div class="cf" style="margin: 0 auto; width: 80%; text-align: center">
            <div class="logo fl"></div>
            <ul class="fr cf" id="main_nav">
                <li class="nav_item lgutipT" title="Questions">
                    <a href="dashboard.php" class="main_link"><img class="img_holder"
                                                       src="images/blank.gif"
                                                       style="background: url(images/icons/computer_imac.png) no-repeat center center"
                                                       alt="Questions"/><span>Questions</span></a><img
                    class="tick tick_a" alt="Objectives" src="images/blank.gif"/></li>
                <li class="nav_item lgutipT" title="Objectives"><a
                    href="objective.php" class="main_link"><img src="images/blank.gif"
                                                                class="img_holder"
                                                                style="background: url(images/icons/file_cabinet.png) no-repeat center center"
                                                                alt="Objectives"/><span>Objectives</span></a><img
                    class="tick tick_a" alt="Scores" src="images/blank.gif"/></li>
                <li class="nav_item lgutipT" title="Scores"><a
                    href="score.php" class="main_link"><img src="images/blank.gif"
                                                   class="img_holder"
                                                   style="background: url(images/icons/image2_2.png) no-repeat center center"
                                                   alt="Scores"/><span>Scores</span></a><img
                    class="tick tick_a" alt="Scores" src="images/blank.gif"/></li>
                    <li class="nav_item lgutipT" title="Schools">
                    <a href="schools.php" class="main_link"><img class="img_holder"
                                                       src="images/blank.gif"
                                                       style="background: url(images/icons/book.png) no-repeat center center"
                                                       alt="Questions"/><span>Schools</span></a><img
                    class="tick tick_a" alt="Schools" src="images/blank.gif"/></li>
                    
                    <li class="nav_item lgutipT" title="Majors">
                    <a href="majors.php" class="main_link"><img class="img_holder"
                                                       src="images/blank.gif"
                                                       style="background: url(images/icons/pencil.png) no-repeat center center"
                                                       alt="Questions"/><span>Majors</span></a><img
                    class="tick tick_a" alt="Schools" src="images/blank.gif"/></li>
                <li class="nav_item lgutipT" title="Students"><a
                    href="student.php" class="main_link"><img src="images/blank.gif"
                                                   class="img_holder"
                                                   style="background: url(images/icons/users2.png) no-repeat center center"
                                                   alt=""/><span>Students</span></a><img
                    class="tick tick_a" alt="Students" src="images/blank.gif"/></li>
                    
                <li class="nav_item lgutipT active" title="Counsellors"><a href="#" class="main_link"><img
                    src="images/blank.gif" class="img_holder"
                    style="background: url(images/icons/create_write.png) no-repeat center center" alt=""/><span>Counsellors</span></a><img
                    class="tick tick_a" alt="Counsellors" src="images/blank.gif"/></li>
                <li class="nav_item lgutipT" title="Reports"><a href="report.php" class="main_link"><img
                    src="images/blank.gif" class="img_holder"
                    style="background: url(images/icons/chart8.png) no-repeat center center"
                    alt=""/><span>Reports</span></a><img class="tick tick_a" alt="" src="images/blank.gif"/></li>
            </ul>
        </div>
    </div>
</div>
<div id="main">
    <div class="wrapper cf">
        <div id="main_section" class="cf brdrrad_a">
            <div id="content_wrapper">
             <?php if (!is_null($saved)) { ?>
                <div class="msg_box <?php echo $saved['type'] ?>"><?php echo $saved['msg'] ?>.<img src="images/blank.gif" class="msg_close" alt="" /></div>
                <?php } ?>
                <form action="#" id="form_a" method="post" novalidate="novalidate">

                    <div class="cf sepH_c">
                        <div id="content_actions" class="fr" style="">
                            <input type="reset" name="reset" value="Reset" class="btn btn_a">
                            <input type="submit" name="save" value="Save" class="btn btn_d">

                        </div>
                        <h1 class="fl">Add A Counselor</h1>
                    </div>
                    <div class="msg_box msg_error" id="form_a_errors" style="display:none"></div>

                    <div class="content_panes">
                        <div id="tab-1" style="display: block; ">

                            <div class="formEl_a" style="background-color:#F8F8F8">

                                <fieldset>
                                    <legend>Add A Counselor</legend>
                                    <div class="sepH_b">
                                        <label for="firstname" class="lbl_a">First Name</label>
                                        <input type="text" id="firstname" name="firstname" class="inpt_a">
                                    </div>
                                     <div class="sepH_b">
                                        <label for="lastname" class="lbl_a">First Name</label>
                                        <input type="text" id="lastname" name="lastname" class="inpt_a">
                                    </div>
                                    <div class="sepH_b">
                                        <label for="age" class="lbl_a">Age</label>
                                        <select name="age" id="age" class="age" style="width: 200px">
                                       		 <option value="choose">Please Choose One</option>
                                            <option value="20-25">20-25 yrs</option>
                                            <option value="25-30">25-30 yrs</option>
                                            <option value="30-40">30-40 yrs</option>
                                            <option value="40+">Above 40 yrs</option>
                                        </select>
                                    </div>
                                    <div class="sepH_b">
                                        <label for="gender" class="lbl_a">Gender</label>
                                        <input type="radio" name="gender" id="gender" value="Male">Male<br>
                                         <input type="radio" name="gender" id="gender" value="Female">Female<br>      
                                    </div>
                                    <div class="sepH_b">
                                        <label for="email" class="lbl_a">Email</label>
                                        <input type="text" id="email" name="email" class="inpt_a">
                                    </div>
                                      <div class="sepH_b">
                                        <label for="date" class="lbl_a">Date</label>
                                        <input type="text" id="datepick" class="inpt_b datepicker required" readonly="readonly" name="reg_date" />
                                    </div>
                                       <div class="sepH_b">
                                        <label for="region" class="lbl_a">Region</label>
                                        <select name="region" id="region" class="region" style="width: 200px">
                                       		 <option value="choose">Please Choose One</option>
                                            <option value="Greater Accra">Greater Accra</option>
                                            <option value="Ashanti Region">Ashanti Region</option>
                                            <option value="Volta Region">Volta Region</option>
                                            <option value="Brong Ahafo Region">Brong Ahafo Region</option>
                                            <option value="Central Region">Central Region</option>
                                            <option value="Western Region">Western Region</option>
                                            <option value="Eastern Region">Eastern Region</option>
                                            <option value="Upper East Region"> Upper East Region</option>
                                            <option value="Upper West Region"> Upper West Region</option>
                                            <option value="Northen Region"> Nothern Region</option>
                                        </select>
                                    </div>
                                     <div class="sepH_b">
                                        <label for="username" class="lbl_a">User Name</label>
                                        <input type="text" id="username" name="username" class="inpt_a">
                                    </div>
                                    <div class="sepH_b">
                                        <label for="password" class="lbl_a">Password</label>
                                        <input type="password" id="password" name="password" class="inpt_a">
                                    </div>
                                    <div class="sepH_b">
                                        <label for="role" class="lbl_a">Role</label>
                                        <select name="role" class="lbl_a required" style="width: 200px">
                                        	<option value="choose">Please Choose One</option>
                                        	<option value="admin">Administrator</option>
                                            <option value="counselor">counselor</option>
                                        </select>
                                    </div>

                                </fieldset>

                            </div>
                        </div>

                       <!-- TABLE  -->
                        <div class="sepH_c">
                            <h2 class="sepH_b">Users</h2>
                            <?php $result = $Counselor->find('ORDER BY `id` ASC'); ?>
                            <?php if ($result) { ?>
                            <table cellpadding="0" cellspacing="0" border="0" class="display formEl_a data_table">
                                <thead>
                                <tr>
                                    <th class="chb_col">
                                        <div class="th_wrapp"><input type="checkbox" class="chSel_all inpt_c1"/></div>
                                    </th>
                                    <th>
                                        <div class="th_wrapp">First Name</div>
                                    </th>
                                    <th>
                                        <div class="th_wrapp">Last Name</div>
                                    </th>
                                   
                                     <th style="width: 100px;">
                                        <div class="th_wrapp">Username</div>
                                    </th>
                                     <th style="width: 100px;">
                                        <div class="th_wrapp">Region</div>
                                    </th>
                                    <th>
                                        <div class="th_wrapp">Role</div>
                                    </th>
                                    <th style="width: 50px;">
                                        <div class="th_wrapp">&nbsp;</div>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>

                                <?php while($counselor = mysql_fetch_object($result)) { ?>
                                <tr data-table="users" data-id="<?php echo $counselor->id; ?>">
                                    <td class="chb_col"><input type="checkbox" name="row_sel" class="inpt_c1"/></td>
                                    <td><?php echo $counselor->firstname; ?></td>
                                  
                                    <td><?php echo $counselor->lastname; ?></td>
                                     <td>   <a href="#edit_form" class="lgutipT edit fncyBx" data-target="edit_form" title="<?php echo $counselor->username ?>"><?php echo strlen($counselor->username) > 50 ? substr($counselor->username, 0, 50) . '...' : $counselor->username; ?></a>
                                    </td>
                                    
                                    <td><?php echo $counselor->region; ?></td>
                                    <td><?php echo $counselor->role; ?></td>
                                    <td>
                                     <?php if ($Counselor->get('role') == 'admin') { ?>
                                        <a href="javascript:void(0);" class="delete delete_all_dt" data-target="delete_form"><img src="images/delete_icon.png" width="12"></a>&nbsp;&nbsp;
                                     <?php } ?>
                                        <a href="#edit_form" class="edit fncyBx" data-target="edit_form"><img src="images/edit.png" width="12"></a>
                                    </td>
                                </tr>

                                <?php } ?>
                                </tbody>
                            </table>
                            <?php }?>
                            
                        </div>
                        <!-- END TABLE-->

                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

<div id="footer">
    <div class="wrapper">
        <div class="cf ftr_content">
            <a href="javascript:void(0)" class="toTop">Back to top</a>
        </div>
    </div>
</div>
<script type="text/javascript">
    head.js(
        "js/jquery-1.7.2.min.js",
        "lib/jquery-ui/jquery-ui-1.8.15.custom.min.js",
        "lib/datatables/jquery.dataTables.min.js",
        "lib/datatables/dataTables.plugins.js",
        "lib/harvesthq-chosen/chosen.jquery.min.js",
        "lib/elfinder/js/elfinder.full.js",
        "lib/visualize/visualize.jQuery.js",
        "lib/visualize/excanvas.js",
        "lib/fusion-charts/FusionCharts.js",
        "lib/gritter/jquery.gritter.min.js",
        "lib/fancybox/jquery.easing-1.3.pack.js",
        "lib/fancybox/jquery.fancybox-1.3.4.pack.js",
        "lib/file-uploader/fileuploader.js",
        "lib/tiny-mce/jquery.tinymce.js",
        "js/jquery.microaccordion.js",
        "js/jquery.stickyPanel.js",
        "js/jquery.text-overflow.min.js",
        "js/xbreadcrumbs.js",
        "lib/slidernav/slidernav.js",
        "lib/styled-checkboxes/iphone-style-checkboxes.js",
        "lib/jquery-raty/jquery.raty.min.js",
        "lib/timepicker-addon/jquery-ui-timepicker-addon.js",
        "js/jquery.faq.js",
        "js/jquery.tools.min.js",
        "lib/jquery-validation/jquery.validate.js",
        "lib/fullcalendar/fullcalendar.min.js",
        "js/lagu.min.js",
        "js/Custom.js",
        function () {
            lga_helper.init();
            lga_bredcrumbs.init();
            lga_scrolltoTop.init();
            lga_messages.init();
            lga_toggleBox.init();
            lga_RemoveBox.init();
            lga_sidebar.lga_accordion();
            lga_sticky.sticky_bredcrumbs();
            lga_slidingPanel.init();
            lga_tips.init();
            lga_externalLink.init();
            lga_datepicker.init();
            lga_datepicker_inline.init();
        }
    );

</script>
<script type="text/javascript"><!--
	head.ready(function() {

        $('.chSel_all').click(function () {
			$(this).closest('table').find('input[name=row_sel]').attr('checked', this.checked);
		});
		$(".delete_all_simple").click(function () {
			$('input[name=row_sel]:checked', '.smpl_tbl').closest('tr').fadeTo(600, 0, function () {
				$(this).remove();
				$('.chSel_all','.smpl_tbl').attr('checked',false);
			});
			return false;
		});

        $('.data_table').dataTable({
			"aaSorting": [[ 1, "asc" ]],
			"aoColumns": [
				{ "bSortable": false },
				null,
				null,
				{ "sType": "formatted-num" },
				{ "sType": "formatted-num" }
			]
		});
	});
--></script>

<!-- MODAL BOX -->
<div style="display:none; width: 60%; ">

    <form id="edit_form" method="post" action="" class="formEl_a">
		
      <fieldset>
      							 <div class="msg_box"><img src="images/blank.gif" class="msg_close" alt="" /></div>
                                    <legend>Edit Counselor</legend>
                                    
                                    <div class="sepH_b">
                                        <label for="firstname" class="lbl_a">First Name</label>
                                        <input type="text" id="firstname" name="firstname" class="inpt_a">
                                    </div>
                                     <div class="sepH_b">
                                        <label for="lastname" class="lbl_a">First Name</label>
                                        <input type="text" id="lastname" name="lastname" class="inpt_a">
                                    </div>
                                    <div class="sepH_b">
                                        <label for="age" class="lbl_a">Age</label>
                                        <select name="age" id="age" class="age" style="width: 200px">
                                       		 <option value="choose">Please Choose One</option>
                                            <option value="20-25">20-25 yrs</option>
                                            <option value="25-30">25-30 yrs</option>
                                            <option value="30-40">30-40 yrs</option>
                                            <option value="40+">Above 40 yrs</option>
                                        </select>
                                    </div>
                                    <div class="sepH_b">
                                        <label for="gender" class="lbl_a">Gender</label>
                                        <input type="radio" name="gender" id="gender" value="Male">Male<br>
                                         <input type="radio" name="gender" id="gender" value="Female">Female<br>      
                                    </div>
                                    <div class="sepH_b">
                                        <label for="email" class="lbl_a">Email</label>
                                        <input type="text" id="email" name="email" class="inpt_a">
                                    </div>
                                      <div class="sepH_b">
                                        <label for="date" class="lbl_a">Date</label>
                                        <input type="text" id="datepick" class="inpt_b datepicker required" readonly="readonly" name="reg_date" />
                                    </div>
                                       <div class="sepH_b">
                                        <label for="region" class="lbl_a">Region</label>
                                        <select name="region" id="region" class="region" style="width: 200px">
                                       		 <option value="choose">Please Choose One</option>
                                            <option value="Greater Accra">Greater Accra</option>
                                            <option value="Ashanti Region">Ashanti Region</option>
                                            <option value="Volta Region">Volta Region</option>
                                            <option value="Brong Ahafo Region">Brong Ahafo Region</option>
                                            <option value="Central Region">Central Region</option>
                                            <option value="Western Region">Western Region</option>
                                            <option value="Eastern Region">Eastern Region</option>
                                            <option value="Upper East Region"> Upper East Region</option>
                                            <option value="Upper West Region"> Upper West Region</option>
                                            <option value="Northen Region"> Nothern Region</option>
                                        </select>
                                    </div>
                                     <div class="sepH_b">
                                        <label for="username" class="lbl_a">User Name</label>
                                        <input type="text" id="username" name="username" class="inpt_a">
                                    </div>
                                    <div class="sepH_b">
                                        <label for="password" class="lbl_a">Password</label>
                                        <input type="password" id="password" name="password" class="inpt_a">
                                    </div>
                                    <div class="sepH_b">
                                        <label for="role" class="lbl_a">Role</label>
                                        <select name="role" class="lbl_a required" style="width: 200px">
                                        	<option value="choose">Please Choose One</option>
                                        	<option value="admin">Administrator</option>
                                            <option value="counselor">counselor</option>
                                        </select>
                                    </div>
 									 <input type="hidden" name="id">
                                </fieldset>
        	<div class="cf sepH_c">
            <div class="fr" style="">
                <input type="reset" name="reset" value="Reset" class="btn btn_a">
                <input type="submit" name="update" value="Update" class="btn btn_d">
            </div>
        </div>
    </form>



</div>
<!-- END MODAL BOX -->
</body>
</html>

</body>
</html>
	


